Palindrome Checker

Check whether a phrase reads the same forwards and backwards

Longest palindrome in the text

What this tool does

Checks whether a sentence reads the same forwards and backwards (a palindrome) and finds the longest palindromic stretch hidden inside it. The result updates with every keystroke, which makes it easy to build a palindrome one letter at a time. Use it for wordplay and language puzzles, classroom material, or checking answers to coding exercises.

How it is calculated

The sentence is cleaned first: English letters are lowercased, and only letters (in any script) and digits are kept, while spaces, punctuation, symbols and emoji are removed. If the cleaned string is identical when reversed, it is a palindrome. The longest palindrome is found by center expansion: each position in the cleaned string is used as a center and widened outward while the characters on both sides match, checking both odd and even lengths. For example, 'Was it a car or a cat I saw?' cleans to 'wasitacaroracatisaw', which reverses to itself, so it is a palindrome. 'My racecar is red' cleans to 'myracecarisred' and is not a palindrome, but the longest-palindrome box shows 'racecar'.

  • Type a sentence in the box. A Korean sample sentence is filled in at first
  • A green box says it is a palindrome; a red box says it is not
  • Below that, 'compared string' shows the actual text compared after removing spaces and symbols
  • The bottom box shows the longest palindromic stretch, without spaces
  • If there are no letters or digits at all, only a prompt to enter a sentence appears

Things to know

  • Spaces and punctuation are ignored, so 'Never odd or even' counts as a palindrome.
  • Digits are treated like letters: 12321 is a palindrome, 12345 is not. The date 2020-02-02 cleans to 20200202, which is one.
  • Case does not matter: 'Level' and 'level' are both palindromes.
  • Korean text is compared syllable by syllable, not by individual consonants and vowels.
  • A single character is always a palindrome, so even a non-palindrome shows at least one letter as its longest palindrome.
  • When writing your own, watch the longest-palindrome box and add matching letters to both ends of it.
  • Checking happens entirely in your browser; your sentence is not saved or sent.

Frequently asked questions

What are some well-known English palindromes?

'A man, a plan, a canal: Panama', 'Never odd or even', 'Was it a car or a cat I saw?' and single words like 'racecar' and 'level'. All read the same once spaces and punctuation are removed.

Does it treat uppercase and lowercase differently?

No. Everything is lowercased before comparing, so 'Madam' and 'madam' give the same result.

How is the longest palindrome found?

By center expansion: every character and every gap between characters is tried as a center and widened while both sides match. If several palindromes share the longest length, the first one is shown.

Is my input sent to a server?

No. All checking is done in your browser and nothing is stored.

← na.to home